<template>
	<view>
		<u-navbar :borderBottom="false" back-text=" " :title="title"></u-navbar>
		<view class="connect">
			<view class="input_form">
				<view class="form_item" style="border-bottom: 1rpx solid #f9f9f9;">
					<u-field maxlength='25' required :clearable="false" placeholderStyle="color:#999;fontSize:24rpx;"
						input-align="right" v-model="form.name" style="width: 100%;fontSize:24rpx;" label="姓名"
						placeholder="请输入姓名"> </u-field>
				</view>
				<view class="form_item" style="border-bottom: 1rpx solid #f9f9f9;">
					<u-field maxlength='20' required :clearable="false" placeholderStyle="color:#999;fontSize:24rpx;"
						input-align="right" v-model="form.wx" style="width: 100%;fontSize:24rpx;" label="微信号"
						placeholder="请输入微信号"> </u-field>
				</view>
				<view class="form_item" style="border-bottom: 1rpx solid #f9f9f9;">
					<u-field label-width="200" maxlength='11' required :clearable="false"
						placeholderStyle="color:#999;fontSize:24rpx;" input-align="right" v-model="form.phone"
						style="width: 100%;fontSize:24rpx;" label="手机号(86)" placeholder="请输入手机号"> </u-field>
				</view>
				<view class="form_item" style="border-bottom: 1rpx solid #f9f9f9;">
					<u-field required type="textarea" :clearable="false" placeholderStyle="color:#999;fontSize:24rpx;"
						input-align="right" v-model="form.reason" style="width: 100%;fontSize:24rpx;" label="申请原因"
						placeholder="请输入申请原因"> </u-field>
				</view>

			</view>
		</view>
		<view style="width: 100%; height: 200rpx;">

		</view>
		<view class="button_submit">
			<u-button @click="onSubmit(2)" class="btns" :custom-style="{'background':'#90c0ff' ,color:'#fff'}"
				:shape="'circle'" :hair-line="false" :ripple="true"
				ripple-bg-color="rgba(9, 82, 200, 0.15)">申请代理</u-button>
		</view>

	</view>
</template>

<script>
	export default {

		data() {
			return {
				title: '申请代理',
				plcstyle: "'color':'#999'",
				form: {
					"name": "", //姓名
					"reason": "", //理由
					"wx": "", //微信号码
					"phone": "" //电话号
				}
			}
		},
		onShow() {

		},
		methods: {
			onSubmit() {
				var isOk = true
				var toast = ''
				try {
					for (var key in this.form) {
						if (!this.form[key]) {
							if (key == 'name') {
								toast = '请输入姓名'
								throw new Error()
							}
							if (key == 'wx') {
								toast = '请输入微信'
								throw new Error()
							}
							if (key == 'phone') {
								toast = '请输入手机号'
								throw new Error()
							}
							if (key == 'reason') {
								toast = '请输入申请原因'
								throw new Error()
							}
						} else {
							if (key == 'phone') {
								if (this.form.phone.length < 11) {
									toast = '请输入正确的手机号'
									throw new Error()
								}
							}
						}
					}
				} catch {
					isOk = false
				}
				if (!isOk) {
					uni.showToast({
						title: toast,
						icon: 'none'
					})
					return
				}
				this.$wqzApi.kor_proxy(this.form).then(res=>{
					uni.showToast({
						title:'提交成功',
						icon:'none'
					})
					setTimeout(()=>{
						uni.navigateBack()
					},1500)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import url(./index.scss);
</style>